public class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode(int x) { val = x; }
     /*
     * 先序遍历
     * */
     public void preOrder(){
         System.out.println(this.val);
         if(this.left != null){
             this.left.preOrder();
         }
         if(this.right!=null){
             this.right.preOrder();
         }
     }

    @Override
    public String toString() {
        return "TreeNode{" +
                "val=" + val +
                ", left=" + left +
                ", right=" + right +
                '}';
    }
}
